/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import java.awt.event.ActionEvent;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;

/**
 *
 * @author KeilyI
 */
@ManagedBean
@SessionScoped
public class LoginBean {

    private String username;  
      
    private String password;  
      
    public String getUsername() {  
        return username;  
    }  
  
    public void setUsername(String username) {  
        this.username = username;  
    }  
  
    public String getPassword() {  
        return password;  
    }  
  
    public void setPassword(String password) {  
        this.password = password;  
    }  
  
    public String login() {            
        if(username != null  && username.equals("admin") && password != null  && password.equals("admin")) {  
//            FacesMessage msg = new FacesMessage("Bienvenido", username);
//            FacesContext.getCurrentInstance().addMessage(null, msg);
            return "opciones";
        } else {  
            FacesMessage msg = new FacesMessage("Usuario y/o Contraseña incorrectos", "");
            FacesContext.getCurrentInstance().addMessage(null, msg);
            return "index";
        }  
          
        
    }  
    
}
